import static java.lang.Thread.sleep;

class Test {

}

public class Demo11 {
//    private static boolean flag;

    public static void main(String[] args) throws InterruptedException {
        boolean flag = false;
        Test test = new Test();
        Thread thread = new Thread(() -> {
//            test = new Test();
            while (!flag) {
                System.out.println(Thread.currentThread().getName());
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        thread.start();

        for (int i = 0; i < 3; i++) {
            System.out.println(Thread.currentThread().getName());
            sleep(1000);
        }
//        flag = true;
    }
}
